home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / SWDOS12 / TEXTSEEK.ASM < prev    next >
Assembly Source File  |  1995-02-10  |  2KB  |  71 lines

  1. ;******************************************************************
  2. ;*                          TEXTSEEK.ASM                          *
  3. ;*          Source file for SoftWeyr enhanced DOS toolbox         *
  4. ;*                           version 1.1                          *
  5. ;*                 Copyright (c) by SoftWeyr,1994                 *
  6. ;******************************************************************
  7. MODEL TPASCAL
  8. include textrec.asm
  9. .DATA
  10.  EXTRN InOutRes:Word
  11. .CODE
  12. PUBLIC TextSeek
  13. TextSeek Proc far F:DWORD,Target:DWORD
  14. LOCAL  Pos : DWORD
  15.        LES DI,F
  16.        CMP ES:[DI].TextRec.Mode,fmInput
  17.        JZ @@1
  18.        MOV InOutRes,104;
  19.        RET
  20. @@1:
  21.       Mov AX,4201H;             {move file pointer function}
  22.       LES DI,F
  23.       MOV BX,ES:[DI].TextRec.Handle[0];          {file handle}
  24.       Sub CX,CX;               {if CX and DX are both 0, call returns the..}
  25.       MOV DX,CX;
  26.       ;{current file pointer in DX:AX}
  27.       INT 21H
  28.       JNC @@2;
  29.       ;{check for I/O error}
  30.       MOV InOutRes,AX
  31.       JMP @@3
  32. @@2:  Mov Word Ptr Pos[2],DX
  33.       MOV Word ptr Pos[0],AX
  34.       MOV InOutRes,0
  35. @@3:  CMP InOutRes,0
  36.       JZ @@4
  37.       RET
  38. @@4:  MOV AX,Word Ptr Pos[0]
  39.       SUB AX,ES:[DI].TextRec.BufEnd
  40.       MOV Word Ptr Pos[0],AX
  41.       JNC @@5
  42.       DEC Word Ptr Pos[2]
  43. @@5:  ;{see if the Target is within the buffer}
  44.       MOV AX,Word Ptr Target[0]
  45.       SUB AX,Word Ptr Pos[0]
  46.       MOV DX,Word Ptr Target[2]
  47.       SBB DX,Word Ptr Pos[2]
  48.       CMP DX,0
  49.       JNZ @@6
  50.       CMP AX,0
  51.       JL @@6
  52.       CMP AX,ES:[DI].TextRec.BufEnd
  53.       JG @@6
  54.       MOV ES:[DI].TextRec.BufPos,AX
  55.       JMP SHORT @@8
  56. @@6:  MOV AX,4200H;         {move file pointer function}
  57.       MOV BX,ES:[DI].TextRec.Handle;        {file handle}
  58.       MOV CX,Word ptr Target[2];    {CX has high word of Target offset}
  59.       MOV DX,Word ptr Target[0];     {DX has low word}
  60.       INT 21H
  61.       JNC @@7
  62.       MOV InOutRes,AX
  63.       JMP @@8
  64. @@7:  MOV InOutRes,0
  65.       MOV ES:[DI].TextRec.BufEnd,0;
  66.       MOV ES:[DI].TextRec.BufPos,0;
  67. @@8:  RET;
  68. endp
  69.  
  70. end
  71.